package com.wuhuahe.learning.lagou.service.code.controller;


import com.wuhuahe.learning.lagou.service.code.pojo.Code;
import com.wuhuahe.learning.lagou.service.code.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private CodeService codeService;

    @GetMapping("/create/{email}")
    public boolean create(@PathVariable("email") String email){
        System.out.println(email);
        Code code = codeService.createCode(email);
        return true;
    }

    @GetMapping("/validate/{email}/{code}")
    public int validate(@PathVariable("email") String email, @PathVariable("code") String code){
        return codeService.validate(email, code);
    }
}
